import ollama,chromadb
from loader import get_config
from llama_index.embeddings.ollama import OllamaEmbedding

embedding = OllamaEmbedding(model_name=r'milkey/dmeta-embedding-zh:f16',
                            base_url="http://localhost:11434")
text = "你好，世界！"
embedding = embedding.get_text_embedding(text)
print(f"嵌入维度: {len(embedding)}")  # 例如 4096 维


embedmodel = get_config()['embedmodel']
chroma = chromadb.HttpClient(host='app3',port=8000)

# 2. Create a collection
# collection = choma.create_collection(
#     name="rag",
#     metadata={"description": "Test collection"}
# )

collection = chroma.get_or_create_collection('rag')

with open('first.txt','rb') as f:
    lines = f.readlines()
    for line in lines:
        embedding = ollama.embed(model='llama3.2',input=line)
        print(embedding)
